import fetch from '../utils/fetch';

////////////////////////////////策略API//////////////////////////////////////
// 获取网关数据列表
export const ApiOfPolicyList = (params) => {
  return fetch({
    url: '/policy/api/w/policys',
    method: 'get',
    params,
  })
}
export const ApiOfPolicyPage = '/policy/api/w/policys/p'
export const ApiOfPolicyEnable = (code) => {
  return fetch({
    url: '/policy/api/w/policys/' + code + '/enable',
    method: 'put',
  })
}
export const ApiOfPolicyDisable = (code) => {
  return fetch({
    url: '/policy/api/w/policys/' + code + '/disable',
    method: 'put',
  })
}
export const ApiOfPolicyCreate = (form) => {
  return fetch({
    url: '/policy/api/w/policys',
    method: 'post',
    data: form,
  })
}
export const ApiOfPolicyUpdate = (code, form) => {
  return fetch({
    url: '/policy/api/w/policys/' + code,
    method: 'put',
    data: form,
  })
}
export const ApiOfPolicyDelete = (code) => {
  return fetch({
    url: '/policy/api/w/policys/' + code,
    method: 'delete',
  })
}
export const ApiOfPolicyBindExpressions = (id, expressions) => {
  return fetch({
    url: '/policy/api/w/policys/' + id + '/bindExpression',
    method: 'put',
    data: expressions,
  })
}
export const ApiOfPolicyBindResources = (code, resources) => {
  return fetch({
    url: '/policy/api/w/policys/' + code + '/bindResource',
    method: 'put',
    data: resources,
  })
}
export const ApiOfPolicyBindLinkages = (code, resources) => {
  return fetch({
    url: '/policy/api/w/policys/' + code + '/bindLinkage',
    method: 'put',
    data: resources,
  })
}
////////////////////////////////策略表达式API//////////////////////////////////////
// 获取网关数据列表
export function ApiOfExpressionList() {
  return fetch({
    url: '/policy/api/w/expressions',
    method: 'get',
  })
}
export const ApiOfExpressionPage = '/policy/api/w/expressions/p'

export const ApiOfExpressionCreate = (form) => {
  return fetch({
    url: '/policy/api/w/expressions',
    method: 'post',
    data: form,
  })
}
export const ApiOfExpressionUpdate = (id, form) => {
  return fetch({
    url: '/policy/api/w/expressions/' + id,
    method: 'put',
    data: form,
  })
}

////////////////////////////////事件API//////////////////////////////////////
// 获取网关数据列表
export const ApiOfEventList = (params) => {
  return fetch({
    url: '/policy/api/w/events',
    method: 'get',
    params,
  })
}
export const ApiOfEventPage = '/policy/api/w/events/p'

export const ApiOfEventRelase = (code) => {
  return fetch({
    url: '/policy/api/w/events/' + code + '/relase',
    method: 'put',
  })
}



